package suncertify;

import suncertify.service.ServiceFactory;
import suncertify.view.client.ClientWindow;
import suncertify.view.server.ServerWindow;

import javax.swing.*;

/**
 * Class - launcher
 */
public class Main {
    /**
     * entry point of the program
     * @param args arguments for program mode
     */
    public static void main(String[] args) {
        if (args.length == 0) {
            System.setProperty(ServiceFactory.MODE, "remote");
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    new ClientWindow().setVisible(true);
                }
            });
        } else if (args[0].equals("server")) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    new ServerWindow().setVisible(true);
                }
            });
        } else if (args[0].equals("alone")) {
            System.setProperty(ServiceFactory.MODE, "local");
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    new ClientWindow().setVisible(true);
                }
            });
        } else {
            System.out.println("Illegal program mode! Run program by following command java -jar runme.jar [server|alone]");
        }
    }
}
